package com.ruyuan.eshop.common.web;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruyuan.eshop.common.core.DateProvider;
import com.ruyuan.eshop.common.core.DateProviderImpl;
import com.ruyuan.eshop.common.core.ObjectMapperImpl;
import com.ruyuan.eshop.common.exception.CustomBlockExceptionHandler;
import com.ruyuan.eshop.common.exception.GlobalExceptionHandler;
import com.ruyuan.eshop.common.json.JsonExtractor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
/**
 <p>
 web相关bean组件配置
 </p>
 * 儒猿课堂: http://www.ruyuan2020.com
 * @Author zhonghuashishan
 * @Remark 有问题直接联系客服VX: ruyuan-1111 ，源码-笔记-技术交流群
 * @Version 1.0
 **/
@Configuration
@Import(value = {GlobalExceptionHandler.class, GlobalResponseBodyAdvice.class})
public class WebConfiguration {

    @Bean
    public ObjectMapper objectMapper() {
        return new ObjectMapperImpl();
    }

    @Bean
    public DateProvider dateProvider() {
        return new DateProviderImpl();
    }

    @Bean
    public JsonExtractor jsonExtractor() {
        return new JsonExtractor();
    }

    @Bean
    public BlockExceptionHandler blockExceptionHandler() {
        return new CustomBlockExceptionHandler();
    }
}